<?php

	$loginError = "";
	if(session_id() == '')
		session_start();

	if(isset($_POST['login'])){
		require('conn.php');
		$username = $_POST['username'];
		$password = $_POST['password'];
		$uidArr = mysql_query("select uid from account where username='$username' and password='$password'");
		if($uid = mysql_fetch_assoc($uidArr)){
                //require_once ('dataBase.php');
                //$input = new dataBase;
                //$uidArr = $input->checkLogin($username , $password);
                //if($input->checkLogin($username , $password)){
                        
                        //$uidArr = mysql_query("select uid from account where username='$username' and password='$password'");
                        //$uid = mysql_fetch_assoc($uidArr); 
			$_SESSION['uid'] = $uid['uid'];
			header('location:'.$_SESSION['link'].'');
		}
		else{
			$loginError = "Incorrect username or password";
		}
		mysql_close($connect);
        }
	
?>
<link type="text/css" rel="stylesheet" href="css/table.css" />
<form action="" method="post">
<div id="table" style="width: 330px">
	<div class="tr">
		<div class="td" style="text-align: left">
		<div style="color: red"><?php echo $loginError?></div>
		<input type="text" name="username" placeholder="Enter Username" size="30">
		</div>
	</div>
	<div class="tr">
		<div class="td" style="text-align: left">
		<input type="password" name="password" placeholder="Enter Password" size="30">
		</div>
	</div>
	<div class="tr">
		<div class="td" style="text-align: left">
		<input type="checkbox" name="remeber"> Remember me (up to 30 days)
		</div>
	</div>
</div>
<div id="table" style="text-align: center">
	<div class="tr">
		<div class="td">
		<input type="submit" name="login" value="SIGN IN">
		</div>
		<div class="td">
		<input type="submit" name="regiseter" value="REGISTER">
		</div>
	</div>
</div>
</form>
